<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@page import="utility.connections"%>
<script type="text/javascript">
	function validate(frm)
	{
		alert(frm.codice.value);
		return false;
		
	}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>NUOVA STANZA</title>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Calibri, Cambria}
.style3 {font-family: Verdana, Calibri, Cambria; font-size: small; }
.style4 {
	font-family: Verdana, Calibri, Cambria;
	font-weight: bold;
	font-style: italic;
	color: #FFFFFF;
}
body {
	background-color: #CCCCCC;
}
-->
</style>
</head>

<body>
<table width="700" height="422" border="0" align="center">
  <tr>
    <td align="center" valign="middle"><img src="images/title.png" width="700" height="100"></td>
  </tr>
  <tr>
    <td height="257" align="center" valign="top"><table width="100%" border="0">
      <tr>
        <td colspan="4" align="center"><div align="left">
          <p class="style3">
          
          <%  
		
			if (session.getAttribute("user")==null)
			response.sendRedirect("loginerr.jsp");
			
			else
			{
	
			String user = session.getAttribute("user").toString();
			String type = session.getAttribute("type").toString();
			String matr = session.getAttribute("matricola").toString();
			String nome = session.getAttribute("nome").toString();
			String cogn = session.getAttribute("cognome").toString();
			
			out.println("Benvenuto " + user);
			}
		%>
		  </p>
        </div></td>
        </tr>
      <tr>
        <td colspan="4" class="style1"><p align="center"><strong>Inserisci i dati della stanza  </strong></p></td>
        </tr>
	  <form  name = "frmStanza" method="post" onsubmit="return validate(this);">
	  <tr>
        <td width="16%" rowspan="5" class="style1">&nbsp;</td>
        <td class="style1"><div align="right">codice:</div></td>
        <td class="style1"><input type="text" name="codice" value="" width="300"/></td>
        <td width="18%" rowspan="5" class="style1">&nbsp;</td>
      </tr>
      <tr>
        <td class="style1"><div align="right">denominazione: </div></td>
        <td class="style1"><input type="text" name="denominazione" value="" width="300"/></td>
        </tr>
      <tr>
        <td class="style1"><div align="right">posizione:</div></td>
        <td class="style1"><input type="text" name="posizione" value="" width="300"/></td>
        </tr>
      <tr>
        <td width="20%" class="style1"><div align="right">note:</div></td>
        <td width="46%" class="style1"><input type="text" name="note" value="" width="300" /></td>
        </tr>
      <tr>
        <td class="style1">&nbsp;</td>
        <td class="style1">
		  <input type="submit" name="btninsert" value="INSERISCI" onClick="this.form.action='insert_stanza'"/>
          <input type="submit" name="btninsert2" value="INDIETRO" onClick="this.form.action='gestione_stanze.jsp'"/></td>
		</tr>
    </form>
	</table>
	</td>
  </tr>
  <tr>
    <td align="center" valign="middle">
    <%@page import = "java.sql.DriverManager"%>
<%@page import = "java.sql.ResultSet"%>
<%@page import = "java.sql.Statement"%>
<%@page import = "java.sql.SQLException"%>

<%! String oracleUser = "azienda";
	String oraclePwd  = "azienda";
	Connection conn;
	String driver;
	String oracle;
	String user;
	String matricola, codicefiscale, nome, cognome; 
	Statement st;
%>
<%
	user = session.getAttribute("user").toString().toLowerCase();
	driver = "oracle.jdbc.driver.OracleDriver";
	oracle = "jdbc:oracle:thin:@localhost:1521:xe"; 
	
	try {
		Class.forName(driver);
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	}
	
	try {
		conn = DriverManager.getConnection(oracle, oracleUser, oraclePwd);
		st = conn.createStatement();
	} catch (SQLException e) {
		e.printStackTrace();
	}
%>
    <%
    	String qry = "select count(*) as totale from stanza";
    	ResultSet rs = st.executeQuery(qry);
    	rs.next();
    	out.println("TOTALE RECORD: " + rs.getString("totale"));
    	
    	rs.close();
    	st.close();
    	conn.close();
    %>
    </td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#000099"><div align="right" class="style4">NUOVA STANZA  </div></td>
  </tr>
</table>
</body>
</html>
